package com.chen.service.impl;

import com.chen.dao.BaseDAO;
import com.chen.pojo.Admin;
import com.chen.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * com.chen.service.impl
 * 作者      : 陈晓
 * 描述      :
 * 创建日期  : 2018/4/29
 * 修改日期  :
 */
@Service("/adminService")
@Transactional
public class AdminServiceImpl implements AdminService {

  @Autowired
  private BaseDAO<Admin> baseDAO;
  public Admin get(Admin admin)throws Exception {
    String hql = "select a from Admin as a where username = ? and password = ?";
    Object[] params =  {admin.getUsername(),admin.getPassword()};
    return baseDAO.get(hql,params);
  }

  @Override
  public Admin get(int adminId) throws Exception {
    String sql = "select a from Admin as a where id = ?";
    Object[] params = {adminId};
    return baseDAO.get(sql,params);
  }

  @Override
  public void update(Admin admin) throws Exception {
    baseDAO.update(admin);
  }
}
